"""
File: tasks.py
Author: J
Date: 2020-02-12
Connect: 
Description:
执行异步任务(异步任务)：发送邮件、发送短信
"""
import time
from main import app


@app.task
def send_email(mail):
    """模拟发送邮件"""
    print('sending mail to %s......' % (mail['to']))
    time.sleep(2)
    print('mail end')
    return 'send mail successful'


@app.task
def add(x, y):
    """模拟计算函数"""
    time.sleep(0.5)
    return x + y